﻿using System;
using SimpleWorkflow.Data;

namespace SimpleWorkflow.Steps
{
    public abstract class EventStep<T> : SimpleStep<T> where T : ISharedFlowContext
    {
        private readonly EventHandler _handler;

        protected EventStep()
        {
           WorkflowContext.EventSurrogates.Publish(EventName, ref _handler); 
        }

        protected void Fire()
        {
            var handlerTmp = _handler;
            if (handlerTmp != null)
                handlerTmp(this, null); // TODO
        }

        protected abstract string EventName { get; }
    }
}
